//
//  ProjectConditionHeader.swift
//  HuaYun
//
//  Created by enghou on 2018/12/18.
//  Copyright © 2018 xyxorigation. All rights reserved.
//

import UIKit

class ProjectConditionHeader: UIView,UITextFieldDelegate {
    @IBOutlet weak var orgField: UITextField!
    @IBOutlet weak var projectNameField: UITextField!
    @IBOutlet weak var yearField: UITextField!
    var delegate: NetProtocol?
    
    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        return false
    }
    
    func textFieldShouldClear(_ textField: UITextField) -> Bool {
        
        if textField.isEqual(self.orgField) {
            self.delegate?.reset()
            return true
        } else {
            textField.text = nil
            self.delegate?.load(with: "detail")
            self.delegate?.load(with: "refresh")
            return true
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        orgField.delegate = self
        projectNameField.delegate = self
        yearField.delegate = self
    }
}
